package club.justwill.single.assembler;

import club.justwill.single.bean.OrderItemResp;
import club.justwill.single.persistence.jpo.OrderItem;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by luoyu on 1/1/16.
 */
@Component
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public class OrderItemAssemble {

    public Object assembleOrderItems(List<OrderItem> orderItemList) {
        List<OrderItemResp> orderItemResps = new ArrayList<OrderItemResp>();
        for(OrderItem orderItem : orderItemList){
            orderItemResps.add(assembleOrderItem(orderItem));
        }
        return orderItemResps;
    }

    public OrderItemResp assembleOrderItem(OrderItem orderItem){
        OrderItemResp orderItemResp = new OrderItemResp();
        orderItemResp.setSkuId(orderItem.getSkuId()+"");
        orderItemResp.setUnits(orderItem.getUnits()+"");
        return orderItemResp;
    }
}
